# -*- coding: utf-8 -*-
#(c)Jonathan & Gregoire (read __doc__ for more information)
#Copyright (C)%(author)s (%(date)s)
#
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program.  If not, see <http://www.gnu.org/licenses/>.

## @packagename pattern
# It is a collection of pattern object for implement MVC pattern design

import time

__author__      = \
"""
Jonathan MERCIER <bioinfornatics at gmail.com >
Gregoire NAUDIN  <greg.naudin at gmail.com    >
"""
__version__     = "$Revision: 0.1 $"
__date__        = "$Date: 2009/23/09$"
__copyright__   = "Copyright (c) 2009 Jonathan MERCIER and Gregoire NAUDIN"
__license__     = "GPL v3 or under"
__name__        = "Player.py"
__description__ = \
"""
Player is used as an abstract class.
Python did'nt have really abstract class!!! 
For this reason do not use this class but their child: Human and Computer class
"""

## Documentation for Player class
# This class is the player definition object
class Player(object):
    ## Class attribute nb_player
    nb_player = 0
    
    ## The constructor
    # @param self: The pointer object
    # @param type: Type of player (human or computer)
    # @param name: player name
    # @param team: number of team player
    # @param score: player score default at 0 but can be change for give an advantage
    def __init__(self,type=None,name=None,team=None,score=0):        
        ## Increase class attribute nb_player
        self.__class__.nb_player += 1

        self.__type             = type
        self.__team             = team
        self.__name             = name
        self.__score            = score
        ## Private attribute __list_card
        # Initialise with a None value for start the list at 1
        self.__list_card        = [None]
    ## A generic answer for private attribute
    # @param self The object pointer
    def private(self):
        print "this attribute is read only"

    ## Public Setter player_type
    # @param self The object pointer
    # @param value: The newest value for player_type variable
    def set_type(self,value):
        self.__type = value
        
    ## Public Getter player_type
    # @param self The object pointer
    def get_type(self):
        return self.__type
    
    ## Property of player_type attribute
    type = property(get_type,set_type)
        
    ## Public Setter team
    # @param self The object pointer
    # @param value: The newest value for team variable
    def set_team(self,value):
        self.__team = value
        
    ## Public Getter team
    # @param self The object pointer
    def get_team(self):
        return self.__team
    ## Property of team attribute
    # @param self The object pointer
    team = property(get_team,set_team)
    
    ## Public Setter name
    # @param self The object pointer
    # @param value Default is None
    def set_name(self,value=None):
        self.__name = value
        
    ## Public Getter name
    # @param self The object pointer
    def get_name(self):
        return self.__name
    
    ## Property of name attribute
    name = property(get_name,set_name)
    
    ## Public Setter score
    # @param self The object pointer
    # @param score The new score (integer)
    def set_score(self,score):
        self.__score = score
        
    ## Public Getter score
    # @param self The object pointer
    def get_score(self):
        return self.__score
    ## property of score attribute
    score = property(get_score,set_score)
    
    ## Public setter list_card
    # @param self The object pointer
    # @param value The newest value to add in list
    def __set_list_card(self,value):
        self.__list_card.append(value)
    
    ## Public getter list_card
    # @param self The object pointer
    def get_list_card(self):
        return [card for card in self.__list_card]
    
    ## property of list_card attribute
    list_card = property(get_list_card,private)
    
    ## Public method take_card
    # @param self The object pointer
    # @param card: A card object
    def take_card(self,card):
        ## set the owner
        card.owner = self.__name
        self.__set_list_card(card)

    ## Public method drop_card
    # @param self The object pointer
    # @param number The card number
    def drop_card(self,number):
        card = self.__list_card.pop(number)
        return card
        
    ## Public method rotate card
    # @param self The object pointer
    # @param number The card number who need be rotate
    # @param degree: Turn card x degree
    def rotate_card(self,number,degree):
        self.__list_card[number].rotate(degree)

    ## Public method left_card
    # @param self The object pointer
    # @return len(self.__list_card) return the number of cards remaining
    def card_remaining(self):
        return len(self.__list_card)-1

    ## Public method left_card
    # @param self The object pointer
    # @param number: The card number
    # @return self.__list_card[number] return a card
    def get_card(self,number):
        return self.__list_card[number]
    
    ## Public method get_card_border_up_left
    # @param self The pointer object
    # @param number The card number
    def get_card_border_up_left(self,number):
        return self.__list_card[number].get_border_up_left()
    
    ## Public method get_card_border_up
    # @param self The pointer object
    # @param number The card number
    def get_card_border_up(self,number):
        return self.__list_card[number].get_border_up()
    
    ## Public method get_card_border_up_right
    # @param self The pointer object
    # @param number The card number
    def get_card_border_up_right(self,number):
        return self.__list_card[number].get_border_up_right()
    
    ## Public method get_card_border_down_left
    # @param self The pointer object
    # @param number The card number
    def get_card_border_down_left(self,number):
        return self.__list_card[number].get_border_down_left()
    
    ## Public method get_card_border_down
    # @param self The pointer object
    # @param number The card number
    def get_card_border_down(self,number):
        return self.__list_card[number].get_border_down()

    ## Public method get_card_border_down_right
    # @param self The pointer object
    # @param number The card number
    def get_card_border_down_right(self,number):
        return self.__list_card[number].get_border_down_right()
    
    ## Public method get_card_border_left
    # @param self The pointer object
    # @param number The card number
    def get_card_border_left(self,number):
        return self.__list_card[number].get_border_left()
    
    ## Public method get_card_border_right
    # @param self The pointer object
    # @param number The card number
    def get_card_border_right(self,number):
        return self.__list_card[number].get_border_right()

    ## Public method take_point
    # @param self: The pointer object
    # @param value: The amount of point win by the player
    def take_point(self,value):
        self.__score += value